package cn.bupt.adt.service;

import cn.bupt.adt.entity.autogenerate.Order;
import cn.bupt.adt.entity.autogenerate.OrderView;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@Service
public interface IOrderService {

    boolean addOrder(Order order, IDoctorService doctorService);

    List<OrderView> getAllOrders();

    List<OrderView> getOverTimeOrders();

    List<OrderView> getUntakedOrders();

    List<OrderView> getTakedAndOperatingOrders();

    List<OrderView> getTakedAndUnoperatedOrders();

    List<OrderView> getTakedAndFinishedOrders();

    List<OrderView> getTakedAndAskForHelpOrders();

    List<OrderView> getFinishedOrders();

    List<OrderView> getCanceledOrders();

    //通过机构id获取该机构发布的所有订单
    List<OrderView> getOrderByInstitutionId(Integer userId);

    /**
     * 机构获取订单列表
     * @param userId
     * @param status
     * @return
     */
    List<OrderView> getOrderByInstitutionIdAndStatus(Integer userId, Integer status);

    Map<String, Object> getCanTakedOrdersByDoctorId(Integer userId, int pageNum, int pageSize, HttpServletRequest request);

    void updateOrderByPrimarykeySelective(Order order);

    OrderView getOrderViewById(int id);

    Order getOrderById(int id);

    //前端接口

    boolean updateOrder(Order order);

    boolean cancelOrderByInst(Order order);

    boolean takeOrder(int orderId, Integer userId);

    Map<String, Object> getOnGoingOrdersOrdersByDoctorId(Integer userId, int pageNum, int pageSize, HttpServletRequest request) throws IllegalAccessException, IOException;

    Map<String, Object> getFinishedOrdersByDoctorId(Integer userId, int pageNum, int pageSize, HttpServletRequest request) throws IOException, IllegalArgumentException, IllegalAccessException;

    boolean instiUpdateOrder(Order order);

    List<OrderView> getChangedOrders();

    Map<String, Object> getUndoOrdersByDoctorId(Integer userId, int pageNum,
                                                int pageSize, HttpServletRequest request) throws IllegalArgumentException, IllegalAccessException, IOException;

    Map<String, Object> getUnfinishOrdersByDoctorId(Integer userId,
                                                    int pageNum, int pageSize, HttpServletRequest request) throws IllegalArgumentException, IllegalAccessException, IOException;

    /**
     * 医生端获取已完成订单
     */
    Map<String, Object> getDoneOrdersByDoctorId(Integer userId, int pageNum, int pageSize, HttpServletRequest request) throws IllegalAccessException, IOException;

    boolean cancelOrder(Order order, Integer id);

}
